package JavaEE_notes.common_API;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

/**
 * @description Random 类
 * @author TaiZai
 * @data 2024/9/19 9:22
 */
public class api_Random {
    public static void main(String[] args) {
/*        Random random = new Random();
        for (int i = 0; i < 10; i++) {
            System.out.println(random.nextInt(10,20));
        }*/
        // 生成中间号码
        int[] randomNum = MakeRandom();
        System.out.println(Arrays.toString(randomNum));
        Scanner sc = new Scanner(System.in);
        int[] in = new int[6];
        for(int i = 0; i < 6; i++) {
            // 输入6位数字
            in[i] = sc.nextInt(10);
        }
        System.out.println(checkNum(randomNum, in));
    }

    public static int[] MakeRandom () {
        // 生成 6 位随机数字
        Random random = new Random();
        int[] arr = new int[6];
        for (int i = 0; i < 6; i++) {
            arr[i] = random.nextInt(10);
        }
        return arr;
    }

    public static String checkNum(int[] arr, int[] in) {
        String res = "未中奖";
        for (int i = 0; i < in.length; i++) {
            if (arr[i] != in[i]) break;
            if(i == 2) res = "三等奖";
            if(i == 3) res = "二等奖";
            if(i == 4) res = "一等奖";
            if(i == 5) res = "特等奖";
        }
        return res;
    }
}
